import requests
import json
url = 'https://api.github.com/user'
headers = {
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"
}

# 这个网址 返回的内容不是html, 而是标准的json
response = requests.get(url,headers=headers)

data = response.content.decode('utf-8')
# str -> dict
data_dict = json.loads(data)

print(data_dict['message'])

# json() 自动将json字符串  转换成为dict list
data_json = response.json()
print(data_json['message'])


